
import exhibition from '../../api/exhibition'
// index.js
const app = getApp()
Page({
  data: {
    banners: [
      { id: 1, imageUrl: 'https://masterjiuyou.oss-cn-hangzhou.aliyuncs.com/d53438b5a8d04d9d8e9545973cebd94c.jpg', title: '现代艺术展' },
      { id: 2, imageUrl: 'https://masterjiuyou.oss-cn-hangzhou.aliyuncs.com/9eddff48800b45cab58e54810b05da3b.jpg', title: '古代陶瓷展' },
      { id: 3, imageUrl: 'https://masterjiuyou.oss-cn-hangzhou.aliyuncs.com/01fd5b33a5a0416aa89b5c89262fc5d0.jpg', title: '自然历史展' }
    ],
    exhibitions: [
      
    ]
  },
  onLoad: function () {
    console.log('首页加载了')
    exhibition.getAllExhibition().then(res => {
      //console.log(res)
      this.setData({
        exhibitions:res.data
      })
      console.log(this.data.exhibitions)
    }).catch(err => {
      console.log(err)
      wx.showToast({ title: err.message || '请求失败' })
    })
  },
  onPullDownRefresh(){
    exhibition.getAllExhibition().then(res => {
      this.setData({
        exhibitions:res.data
      })
    }).catch(err => {
      console.log(err)
      wx.showToast({ title: err.message || '请求失败' })
    })
  },
  goToExhibition: function (e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../exhibition/exhibition?id=' + id
    })
  },
  gotoSearch(){
    wx.navigateTo({
      url: '/pages/search/search'
    })
  },
  
})
